<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>已知宽高</title>
    <!--总结 1、不管是已知宽高还是未知宽高都用translate属性设置垂直水平居中
        用margin还需额外考虑盒子边框的宽度
        2、可以使用弹性盒子处理-->
    <style>
        .box1{
            border : green 2px solid;
            width: 700px;
            height: 300px;
            position: relative;
        }
        .box2{
            border : red 40px solid;
            width: 100px;
            height: 100px;
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            /*margin: -90px 0 0 -90px;*/
        }
    </style>
</head>
<body>
    <div class="box1">
        <div class="box2"></div>
    </div>
</body>
</html>